package com.orphan.audit.controller;


import com.orphan.audit.po.Supplier;
import com.orphan.audit.service.ISupplierService;
import com.orphan.util.dto.SupplierInfoDto;
import org.apache.ibatis.annotations.Insert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yichen
 * @since 2021-07-14
 */
@RestController
@RequestMapping("/supplier")
public class SupplierController {
    @Autowired
    ISupplierService iSupplierService;
    SupplierInfoDto supplierFreezeDto;

    @GetMapping("/getAll")
    public List<Supplier> getAll(){
        List<Supplier> suppliers = iSupplierService.getAll();
        return suppliers;
    }

    @GetMapping("/update/{id}/{status}/{rank}")
    public boolean update(@PathVariable("id") Integer id, @PathVariable("status") String status,@PathVariable("rank")  String rank){
        Supplier supplier = new Supplier();
        supplier.setId(id);
        supplier.setStatus(status);
        supplier.setRank(rank);
        System.out.println("supplier = " + supplier);
        boolean update = iSupplierService.Update(supplier);
        return update;
    }

    @GetMapping("/add")
    public boolean add(){
        Supplier supplier = new Supplier();
        supplier.setUsername(supplierFreezeDto.getUsername());
        supplier.setPassword(supplierFreezeDto.getPassword());
        supplier.setGender(supplierFreezeDto.getGender());
        supplier.setTel(supplierFreezeDto.getTel());
        supplier.setIdpic(supplierFreezeDto.getIdPic());
        supplier.setBrand(supplierFreezeDto.getBrand());
        supplier.setStatus(supplierFreezeDto.getStatus());
        supplier.setLicensepic(supplierFreezeDto.getLicensePic());
        supplier.setRank(supplierFreezeDto.getBrand());
        System.out.println("supplier = " + supplier);
        boolean update = iSupplierService.Update(supplier);
        return update;
    }



}
